<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>form表单</title>
</head>
<body>

    <form action="javascript:void(0)" id="form">
         <input type="text" name="userName">
         <input type="number" name="age">
         <!-- <input type="submit" id="submit"> -->
    </form>

    <button id="submit">点击发送</button>

    <script >

        let submitBtn = document.getElementById("submit");

        let form = document.getElementById("form");

        submitBtn.addEventListener("click", function(event){
            // let params = {
            //     userName:form.userName.value,
            //     age:form.age.value
            // }

            let params = {
                userName:'wkf',
                age:12,
                sex:1,
                email:'<EMAIL>',
                home:'luoyang'  
            }
            let urlParams = new URLSearchParams(params).toString()
            fetch('http://localhost:8080/getUsers?'+urlParams).then(res => {
               const contentType = res.headers.get('content-type')
               console.log(contentType)
               return res.json()
            }).then(data=> {
                 console.log(data)  
            })  

            
            
            

        })



    </script>
    
</body>
</html>